#include <stdio.h>
#include "softfloat.h"

/* float_status status; */

void dpi_init()
{
  status.float_detect_tininess = float_tininess_after_rounding;
  status.float_rounding_mode = float_round_nearest_even;
  status.float_exception_flags = 0;
  status.floatx80_rounding_precision = 0;
  status.flush_to_zero = 0;
  status.flush_inputs_to_zero = 0;
  status.default_nan_mode = 0;

  printf("dpi init ...... \n");
}

int get_exception()
{
  return status.float_exception_flags;
}

void clear_exception()
{
  status.float_exception_flags = 0;
}



void set_tininess_detect(int mode)
{
  if(mode == 0)
    status.float_detect_tininess = float_tininess_after_rounding;
  else
    status.float_detect_tininess = float_tininess_before_rounding;
}

void set_rounding_mode(int rounding_mode)
{
  if(rounding_mode >=0 && rounding_mode <= 3)
    status.float_rounding_mode = rounding_mode;
  else
    {
      printf("rounding_mode [%d] not valid\n", rounding_mode);
    }
}
